package com.oa.core.utils.request;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.Map;

@Data
public class RJsonParam extends RParam {

    public RJsonParam() {
        super.setPageNum(0);
        super.setPageNum(10);
    }

    public RJsonParam(String json) {
        this.paramMap = JSONObject.parseObject(json);
        this.setPageNum(Integer.valueOf(String.valueOf(this.paramMap.get("pageNum"))));
        this.setPageSize(Integer.valueOf(String.valueOf(this.paramMap.get("pageSize"))));
    }

    private Map paramMap;

    @Override
    public String getString(String key) {
        return String.valueOf(paramMap.get(key));
    }

    @Override
    public boolean paramExist(String ... key) {
        for(String temp: key){
            if(this.paramMap.containsKey(temp) == false){
                return false;
            }
        }
        return true;
    }

}
